/**************************************************************************
 * Copyright (C) 2017-2017  Unisound
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 **************************************************************************
 *
 * Description : user_adc.h
 * Author      : yuanshifeng@unisound.com
 * Date        : 2020.04.24
 *
 **************************************************************************/
#ifndef USER_INC_USER_ADC_H_
#define USER_INC_USER_ADC_H_

#ifdef __cplusplus
  extern "C" {
#endif

#include "unione.h"

/** @addtogroup uni_adc_def
@{*/

/// ADC通道选择
typedef enum {
  ADC_AIN2 = 2,
  ADC_AIN3 = 3
}ADC_AIN_SEL;

/** @}*/

/** @addtogroup uni_adc_inf
@{*/

/**
*@brief ADC初始化
*@retval 0
*/
int user_adc_init(void);

/**
*@brief ADC初始化
*@param adc_ain ADC编号
*@param *value ADC读取值，范围0~4095
*@retval 0
*/
int user_adc_get_value(ADC_AIN_SEL adc_ain, int *value);

/**
*@brief ADC开始工作
*@retval 0 操作成功
*@retval -1 操作失败
*/
int user_adc_start(void);

/**
*@brief ADC反初始化
*@retval 0 操作成功
*/
int user_adc_final(void);

/** @}*/

#ifdef __cplusplus
}
#endif
#endif

